
//2824.统计和小于目标的下标对数目
class Solution {
public:
    int countPairs(vector<int>& nums, int target) {
        sort(nums.begin(),nums.end());
        
        int left=0,right=nums.size()-1;
        int ret=0;
        while(left<right)
        {
            if(nums[left]+nums[right]<target)
            {
                ret+=right-left;
                left++;
            }
            else 
                right--;
        }
        return ret;
    }
};